package com.company.testJSoup;


import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import javax.xml.crypto.Data;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

/**
 * Created by v on 17-4-6.
 */
public class Main {
    public static void main(String[] args) throws IOException{
        File file=new File("/home/v/IdeaProjects");
        statistics(file.listFiles());

        System.out.println("自从装了idea以来共写了"+number+"行java代码");
    }

    public static int number=0;

    public static void statistics(File[] files) throws IOException{
        for(int i=0;i<files.length;i++){
            if(files[i].isDirectory()){
                statistics(files[i].listFiles());
            }else {
                addCode(files[i]);
            }
        }
    }

    public static void addCode(File file) throws IOException{
        Scanner input=new Scanner(file);
        if (!file.getName().contains(".java")){
            return;
        }else {
            while (input.hasNext()){
                String line=input.nextLine();
                if(!line.equals("")){
                    number++;
                }
            }
        }
    }
}
